Date functions are used to perform a number of common calculations which frequently appear in rules.
Be sure to use the exact syntax for these functions including spacing and parentheses as specified below. Date and number inputs may be either constant values or variables.
Note that in date calculations attempting to exceed the allowable date range with a date too far in the past or future will lead to the Earliest or Latest value as appropriate.
Function | Example rule | Inputs |
Outputs |
Further information |
---|---|---|---|---|
CurrentDate |
|
today's date: 2005-04-15 today's date: 2009-08-31 |
today = 2005-04-15 the date of the investigation = 2009-08-31 |
Get today's date |
Date |
|
2012-01-01 | the date of effect = 2012-01-01 | Convert a text string into a number or date |
MakeDate |
|
yyyy: 2006; mm: 10; dd: 19 |
the calculation date = 2006-10-19 | Get a date formed from a specified year, month and day |
ExtractDay |
|
the use-by date on the packet: 2008-06-12 | the day of expiry = 12 | Get the day component of an input date |
ExtractMonth |
|
the use-by date on the packet: 2007-04-16 | the month of expiry = 04 | Get the month component of an input date |
ExtractYear |
|
the use-by date on the packet: 2009-02-21 | the year of expiry = 2009 | Get the year component of an input date |
NextDayOfTheWeek |
|
the current date: 2009-08-09 |
next Monday = 10 August 2009 next Tuesday = 11 August 2009 last Thursday = 6 August 2009 |
Get the date of the next or previous specified day |
AddDays |
|
the date of loan: 2006-01-04
the date of the show: 2007-05-15 |
the date that the library book must be returned by = 25
the closing date for the entry = 2007-05-05 |
Add or subtract a specified number of days to an input date |
AddWeeks |
|
the date that the event begins: 2001-08-13 the number of weeks in the event: 12
the end date of the promotion: 2008-12-24 |
the date that the event finishes = 2001-11-05
the start date of the 5 week promotion = 2008-11-19 |
Add or subtract a specified number of weeks to an input date |
AddMonths |
|
the date of the suspension: 2005-12-12
the end date of the player's contract: 2006-06-30 |
the date that the player can return from suspension = 2006-03-12
the start date of the player's 12 month contract = 2005-06-30 |
Add or subtract a specified number of months to an input date |
AddYears |
|
the date of the crime: 2002-01-01
the date that the prison sentence ends: 1980-03-16 |
the date of the trial = 2005-01-01
the date that the prison sentence starts = 1960-03-16 |
Add or subtract a specified number of years to an input date |
YearStart |
|
the date of the grand occasion: 2007-09-09 |
the start of the first relevant year = 2009-01-01 the start of the second relevant year = 2007-01-01 |
Find the first date in the year |
YearEnd |
|
the relevant date: 2005-10-15 | the end of the relevant year = 2005-12-31 | Find the last date in the year |
NextDate |
|
the test date: 2005-07-02 |
the end of the Australian tax year = 2006-06-30 |
Find the next instance of the given day/month |
UKTaxYearDates |
|
the test date: 2003-09-21 |
the date of effect = 2004-04-05
the assessment date = 2003-04-06 |
Find the start or the end date for the previous or next UK tax year |
WeekdayCount |
|
date1: 2007-12-03; date2: 2007-12-13 date1: 2007-10-15; date2: 2007-10-31 |
the number of working days until my holiday = 8 the number of business days in the specified period = 12 |
Count the number of weekdays between two dates |
DayDifference |
|
date1: 2006-10-01 date2: 2006-10-14 |
the number of days in the assessment period = 13 | Count the number of whole days between two dates |
DayDifferenceInclusive |
|
date1: 2006-10-01 date2: 2006-10-14 |
the number of days in the assessment period = 14 | |
DayDifferenceExclusive |
|
date1: 2006-10-01 date2: 2006-10-14 |
the number of days in the assessment period = 12 | |
WeekDifference |
|
the current date: 2011-11-25 |
the number of weeks remaining = 4 | Count the number of whole weeks between two dates |
WeekDifferenceInclusive |
|
the current date: 2011-11-25 | the number of weeks remaining = 5 | |
WeekDifferenceExclusive |
|
the current date: 2011-11-25 | the number of weeks remaining = 3 | |
MonthDifference |
|
the current date: 2011-11-28 the expiry date of the contract: 2013-03-24 |
the number of months remaining = 15 | Count the number of whole months between two dates |
MonthDifferenceInclusive |
|
the current date: 2011-11-28 the expiry date of the contract: 2013-03-24 |
the number of months remaining = 16 | |
MonthDifferenceExclusive |
|
the current date: 2011-11-28 the expiry date of the contract: 2013-03-24 |
the number of months remaining = 14 | |
YearDifference |
|
the date the tree was planted: 2000-03-12 the date the tree was assessed: 2003-12-12 |
the age of the tree in years = 3 | Count the number of whole years between two dates |
YearDifferenceInclusive |
|
the date the tree was planted: 2000-03-12 the date the tree was assessed: 2003-12-12 |
the age of the tree in years = 4 | |
YearDifferenceExclusive |
|
the date the tree was planted: 2000-03-12 the date the tree was assessed: 2003-12-12 |
the age of the tree in years = 2 |
TIP: The localized syntax for these functions may be viewed:
See also: